package com.depot.basedata.companyInfo.web;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;



import com.depot.basedata.companyInfo.dao.TcCompanyDao;
import com.depot.basedata.companyInfo.domain.TcCompany;
import com.soar.BaseActionSupport;
import com.soar.context.Environment;

public class TcCompanyAction extends BaseActionSupport
{

	private static final long serialVersionUID = 1L;

	public TcCompany domain = new TcCompany();

	public HashMap<String, String> map = new HashMap<String, String>();
	
	public List<HashMap<String,String>> companyTypeList =  new ArrayList<HashMap<String,String>>();

	public String execute(Environment env) throws Exception
	{
		this.sysPageList = TcCompanyDao.select(env, domain, this);
		return "list";
	}

	public String doSave(Environment env) throws Exception
	{
		String result = TcCompanyDao.doSave(env, domain);
		if (result.equals("1"))
		{
			this.setMessage("保存数据成功");
		}
		else
		{
			this.setMessage("保存数据失败");
		}
		return this.execute(env);
	}

	public String add(Environment env) throws Exception
	{
		this.companyTypeList = TcCompanyDao.seletCompayType(env, "31", "-100");
		return "add";
	}

	public String edit(Environment env) throws Exception
	{
		this.companyTypeList = TcCompanyDao.seletCompayType(env, "31", "-100");
		this.map = TcCompanyDao.getCompanyById(env, domain);
		return "edit";
	}

	public String del(Environment env) throws Exception
	{
		String result = TcCompanyDao.delCompany(env, domain);
		if (result.equals("1"))
		{
			this.setMessage("保存数据成功");
		}
		else
		{
			this.setMessage("保存数据失败");
		}
		return this.execute(env);
	}

}
